<?php

/**
 * model_resource
 */

class Model_resource extends YOU {

	public function __construct()
	{
		parent::__construct();
	}

	/** 读取总数 **/
	public function count()
	{
		$row = $this->db->fetchRow("SELECT COUNT(1) AS count FROM `tbl_resource`");
		
		$count = (int)$row['count'];
		
		return $count;
	}
	
	
	/** 读取成配置 **/
	public function getIni()
	{
		$resource_lists = $this->getAll();
		foreach ($resource_lists as $key => $value){
			$resource[$value['resource_id']] = $value['resource_name'];
		}

		return $resource;
	}

	/** 读取列表 **/
	public function getAll($field = "*")
	{
		$resource_lists = $this->db->fetchAll("SELECT {$field} FROM `tbl_resource` ");

		return $resource_lists;
	}

	/** 得到数据 **/
	public function getInfo($resource_id, $field = "*")
	{
		$resource_data = $this->db->fetchRow("SELECT {$field} FROM `tbl_resource` WHERE resource_id='{$resource_id}'");

		return $resource_data;
	}
	/** 得到分类数据 **/
	public function getPartInfo($part_id, $field = "*")
	{
		$part_data = $this->db->fetchRow("SELECT {$field} FROM `tbl_resource_part` WHERE part_id='{$part_id}'");

		return $part_data;
	}
	/** 得到分类数据 **/
	public function getPartAll($field = "*")
	{
		$part_lists = $this->db->fetchAll("SELECT {$field} FROM `tbl_resource_part`");

		return $part_lists;
	}


}



?>